//
//  LHNavigationController.swift
//  Swift3.0WB
//
//  Created by 美食家 on 17/3/28.
//  Copyright © 2017年 不孤独的美食家. All rights reserved.
//

import UIKit

class LHNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationBar.isHidden=true
    }
    
    func leftBtnClick() -> Void {
        popViewController(animated: true)
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        
        if childViewControllers.count>0{
            viewController.hidesBottomBarWhenPushed=true
            
            if let vc=viewController as? LHBaseController{
                
                var title="返回"
                
                if childViewControllers.count==1{
                   title=childViewControllers.first?.title ?? "返回"
                }
                
                vc.navItem.leftBarButtonItem=UIBarButtonItem(title: title, target: self, action: #selector(leftBtnClick), isBack: true)
            
            }
        }
        
        super.pushViewController(viewController, animated: true)
    }

}
